#pragma once
#include "xnamath.h"
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef XMVECTOR Quat;
typedef XMVECTOR vec;

typedef XMFLOAT4 float4;
typedef XMFLOAT3 float3;
typedef XMFLOAT2 float2;
typedef XMFLOAT4X4 float4x4;

typedef XMFLOAT4A float4a;
typedef XMFLOAT3A float3a;
typedef XMFLOAT2A float2a;
typedef XMFLOAT4X4A float4x4a;
inline float3 add(float3& a, float3& b)
{
	float3 result;
	XMVECTOR va = XMLoadFloat3(&a);
	XMVECTOR vb = XMLoadFloat3(&b);
	XMVECTOR r = XMVectorAdd(va, vb);
	XMStoreFloat3(&result, r);
	return result;
}
struct Size
{
	Size() : w(0), h(0) { }
 	Size(uint pw, uint ph) : w(pw), h(ph) { }

	uint w; uint h;
};


inline vec to_vec(float3 v)
{
	return XMLoadFloat3(&v);
}
inline vec to_vec(float4 v)
{
	return XMLoadFloat4(&v);
}
inline void to_float3(vec vec, float3& f3)
{
	return XMStoreFloat3(&f3, vec);
}
inline void to_float4(vec vec, float4& f4)
{
	return XMStoreFloat4(&f4, vec);
}

inline void to_float3a(vec vec, float3a& f3)
{
	return XMStoreFloat3A(&f3, vec);
}
inline void to_float4a(vec vec, float4a& f4)
{
	return XMStoreFloat4A(&f4, vec);
}
namespace vec4
{
	inline vec zero()
	{
		return XMVectorSet(0, 0, 0, 1);
	}
	inline vec forward()
	{
		return XMVectorSet(0, 0, 1, 0);
	}
	inline vec up()
	{
		return XMVectorSet(0, 1, 0, 0);
	}
	inline vec left()
	{
		return XMVectorSet(-1, 0, 0, 0);
	}

}
namespace quat
{
	inline vec rotate(vec v, Quat q)
	{
		return XMQuaternionMultiply(XMQuaternionMultiply(q, v), XMQuaternionConjugate(q));
	}
}